package fun.werfamily.wf.user.core.domain.dto.resp;

import fun.werfamily.wf.user.core.domain.exception.UserCoreException;
import lombok.Data;

/**
 * @Author: Mr.WenMing Zhang
 * @Date: 2022/07/27 17:10
 * @Description:
 **/
@Data
public  class Response<T> {
    private static final String SUCCESS_CODE = "200";
    private static final String SUCCESS_MSG = "ok";
    private static final String ERROR_CODE = "1001";
    private static final String ERROR_MSG = "系统繁忙，请稍后重试!";
    private String code;
    private String msg;
    private T data;
    public Response(){

    }
    public Response(T data){
        this.data = data;
        this.code = SUCCESS_CODE;
        this.msg = SUCCESS_MSG;
    }

    public Response(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public Response(UserCoreException userCoreException){
        this.code = userCoreException.getCode();
        this.msg = userCoreException.getMsg();
    }
//
//    public Response(String msg){
//        this.code = ERROR_CODE;
//        this.msg = ERROR_MSG;
//    }

//    public static Response buildSuccess(T data){
//        Response response = new Response();
//        response.setCode(SUCCESS_CODE);
//        response.setMsg(SUCCESS_MSG);
//        response.setData(data);
//        return response;
//    }
}
